package com.yupi.project.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yupi.project.common.ErrorCode;
import com.yupi.project.exception.BusinessException;
import com.yupi.project.mapper.InterfaceInfoMapper;
import com.yupi.project.model.domain.InterfaceInfo;
import com.yupi.project.service.InterfaceInfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 有点儿意思
 * @Description:
 */
@Service
public class InterfaceInfoServiceImpl extends ServiceImpl<InterfaceInfoMapper,InterfaceInfo> implements InterfaceInfoService {


    @Override
    public void validInterFaceInfo(InterfaceInfo interfaceInfo, boolean add) {
        if (interfaceInfo == null){
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        String name = interfaceInfo.getName();
       if (add){
           if (StringUtils.isEmpty(name)){
               throw new BusinessException(ErrorCode.PARAMS_ERROR);
           }
           if (StringUtils.isNotBlank(name) && name.length() > 50){
               throw new BusinessException(ErrorCode.PARAMS_ERROR,"名称过长");
           }
       }

    }
}
